{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Wind power station units"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "According to IEC 60909-0:2016, wind power station units are considered as impedance for the following types:\n",
    "* Wind power station unit with asynchronous generator (6.8.2)\n",
    "* Wind power station unit with doubly fed asynchronous generator (6.8.3)\n",
    "\n",
    "Wind power station units with full size converter are considered as current source injections, and the contributions to the short-circuit current are specified by the datasheet of the manufacturer (6.9)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example grid"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For all the further examples, we use the following grid model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:57.136933Z",
     "start_time": "2025-10-17T08:25:51.330390Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandapower.shortcircuit as sc\n",
    "from pandapower.test.shortcircuit.test_sgen import simplest_test_grid as create_net"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The grid model has one node, one ext_grid (with near 0 contribution, for the purpose of convergence) and a static generator:\n",
    "\n",
    "$\n",
    "X\\\\\n",
    "|\\\\\n",
    "\\cdot\\\\\n",
    "|\\\\\n",
    "G\\\\\n",
    "$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Wind power station unit with asynchronous generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The impedance $Z_G$ of the asynchronous generator is calculated as follows:\n",
    "\n",
    "\n",
    "$Z_{WD} = \\frac{1}{I_{LR} / I_{rG}} \\cdot \\frac{U_{rG}}{\\sqrt{3} \\cdot I_{rG}} = \\frac{1}{I_{LR} / I_{rG}} \\cdot \\frac{U_{rG}^2}{S_{rG}}$\n",
    "\n",
    "The complex value of $\\underline{Z}_G$\n",
    "\n",
    "$\\underline{Z}_G = R_G + jX_G = (\\frac{R_G}{X_G}+j) \\cdot \\frac{Z_G}{\\sqrt{1 + (R_G/X_G)^2}}$\n",
    "\n",
    "If $R_G/X_G$ is not provided by the manufacturer, then it can be assumed as 0.1\n",
    "\n",
    "The total positive-sequence short-circuit impedance $\\underline{Z}_{WA}$ of a wind power station unit with asynchronous generator for the calculation of the short-circuit current contribution on the high-voltage side of the unit transformer is calculated as follows:\n",
    "\n",
    "$\\underline{Z}_{WA} = t_r^2 \\cdot \\underline{Z}_G + \\underline{Z}_{THV}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Required parameters for sgen are:\n",
    "\n",
    "* U_rG: rated voltage of the asynchronous generator (we take from the bus)\n",
    "* I_rG: rated current of the asynchronous generator (calculated from S_rG and U_rG)\n",
    "* S_rG: rated apparent power of the asynchronous generator (required input)\n",
    "* R_G/X_G: R to X value of the asynchronous generator (required input)\n",
    "\n",
    "Required new input parameter:\n",
    "* I_LR/I_rG: the ratio of the symmetrical locked-rotor current to the rated current of the asynchronous generator (required new input, provided by the manufacturer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:57.152719Z",
     "start_time": "2025-10-17T08:25:57.146196Z"
    }
   },
   "outputs": [],
   "source": [
    "U_rG = 0.4  # kV\n",
    "S_rG = 2.5 # MVA\n",
    "I_rG = S_rG / (np.sqrt(3) * U_rG)\n",
    "I_LR = 5 * I_rG # our assumption\n",
    "I_LR_rG = I_LR / I_rG\n",
    "RX_G = 0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:57.466405Z",
     "start_time": "2025-10-17T08:25:57.448271Z"
    }
   },
   "outputs": [],
   "source": [
    "Z_G = 1/I_LR_rG * U_rG**2 / S_rG\n",
    "Z_G"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:57.793309Z",
     "start_time": "2025-10-17T08:25:57.778070Z"
    }
   },
   "outputs": [],
   "source": [
    "Z_G_complex = (RX_G + 1j) * Z_G / (np.sqrt(1 + RX_G**2))\n",
    "Z_G_complex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:58.167142Z",
     "start_time": "2025-10-17T08:25:58.151643Z"
    }
   },
   "outputs": [],
   "source": [
    "t_r = 20/0.4\n",
    "# transformer impedance is taken from the pandapower grid\n",
    "# transformer from the example (see below)\n",
    "Z_THV_complex = 2.3263781460713675+9.409936797295378j\n",
    "Z_WA_complex = t_r ** 2 * Z_G_complex + Z_THV_complex\n",
    "Z_WA_complex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:58.473598Z",
     "start_time": "2025-10-17T08:25:58.452917Z"
    }
   },
   "outputs": [],
   "source": [
    "ikss_ka = 1.1 * 0.4 / (np.sqrt(3) * Z_G)\n",
    "ikss_ka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:58.783176Z",
     "start_time": "2025-10-17T08:25:58.761025Z"
    }
   },
   "outputs": [],
   "source": [
    "# skss\n",
    "ikss_ka * 0.4 * np.sqrt(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:59.080591Z",
     "start_time": "2025-10-17T08:25:59.049213Z"
    }
   },
   "outputs": [],
   "source": [
    "ikss_block_ka = 1.1 * 20 / (np.sqrt(3) * abs(Z_WA_complex))\n",
    "ikss_block_ka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:59.424724Z",
     "start_time": "2025-10-17T08:25:59.406049Z"
    }
   },
   "outputs": [],
   "source": [
    "# skss\n",
    "ikss_block_ka * 20 * np.sqrt(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:25:59.750788Z",
     "start_time": "2025-10-17T08:25:59.727282Z"
    }
   },
   "outputs": [],
   "source": [
    "kappa = 1.02 + 0.98 * np.exp(-3*0.1)\n",
    "ikss_ka * kappa * np.sqrt(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:00.155958Z",
     "start_time": "2025-10-17T08:26:00.130736Z"
    }
   },
   "outputs": [],
   "source": [
    "kappa_block = 1.02 + 0.98 * np.exp(-3 * Z_WA_complex.real / Z_WA_complex.imag)\n",
    "ikss_block_ka * kappa_block * np.sqrt(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:03.247360Z",
     "start_time": "2025-10-17T08:26:00.486029Z"
    }
   },
   "outputs": [],
   "source": [
    "%%capture\n",
    "# now with pandapower:\n",
    "net = create_net(\"async\", step_up_trafo=True)\n",
    "sc.calc_sc(net, ip=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:03.295471Z",
     "start_time": "2025-10-17T08:26:03.257404Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.sgen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.138692Z",
     "start_time": "2025-10-17T08:26:04.115458Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.res_bus_sc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Wind power station units with doubly fed asynchronous generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The total positive-sequence short-circuit impedance $Z_{WD}$ of a wind power station is defined as follows (eq. 28):\n",
    "\n",
    "$Z_{WD} = \\frac{\\sqrt{2} \\cdot \\kappa_{WD} \\cdot U_{rTHV}}{\\sqrt{3} \\cdot i_{WDmax}}$\n",
    "\n",
    "where\n",
    "\n",
    "$U_{rTHV}$ stands for the rated voltage of the unit transformer at the high-voltage side\n",
    "\n",
    "$\\kappa_{WD}$ is the factor for the caclulation of the peak short-circuit current, given by the manufacturer and referred to the high-voltage side (depends on the protection equipment, to be assumed 1.7 if not known)\n",
    "\n",
    "$i_{WDmax}$ is the highest instantaneous short-circuit value in case of a three-phase short-circuit\n",
    "\n",
    "\n",
    "\n",
    "The complex value of the short-circuit impedance $\\underline{Z}_{WD}$ is calculated as follows (eq. 29):\n",
    "\n",
    "$\\underline{Z}_{WD} = R_{WD} + jX_{WD} = (\\frac{R_{WD}}{X_{WD}}+j) \\cdot \\frac{Z_{WD}}{\\sqrt{1+(R_{WD}/X_{WD})^2}}$\n",
    "\n",
    "If $\\frac{R_{WD}}{X_{WD}}$ is not provided by the manufacturer, then 0.1 can be assumed."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Required parameters for sgen are:\n",
    "\n",
    "* U_rG: rated voltage of the asynchronous generator (we take from the bus)\n",
    "* I_rG: rated current of the asynchronous generator (calculated from S_rG and U_rG)\n",
    "* S_rG: rated apparent power of the asynchronous generator (required input)\n",
    "* R_G/X_G: R to X value of the asynchronous generator (required input)\n",
    "\n",
    "Required new input parameters:\n",
    "* i_WDmax: the highest instantaneous short-circuit value in case of a three-phase short-circuit (required new input, provided by the manufacturer)\n",
    "* k_WD: (kappa) the factor for the calculation of the peak short-circuit current, referred to the high-voltage side (required new input, provided by the manufacturer)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculation according to the example from IEC 60909-4:2021 (8.2, figure 16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.464676Z",
     "start_time": "2025-10-17T08:26:04.455331Z"
    }
   },
   "outputs": [],
   "source": [
    "S_rWd = 2.5 # MVA\n",
    "U_rWD = U_rTWDHV = 20 # kV\n",
    "i_WDmax = 0.388 # kA\n",
    "# I_rWD is provided by the manufacturer\n",
    "# i_kWDmax = 1.2 * I_rWD\n",
    "k_WD = 1.7\n",
    "RX_WD = 0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.620856Z",
     "start_time": "2025-10-17T08:26:04.600530Z"
    }
   },
   "outputs": [],
   "source": [
    "Z_WD = np.sqrt(2) * k_WD * U_rTWDHV / (np.sqrt(3) * i_WDmax)\n",
    "Z_WD # Ohm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.651456Z",
     "start_time": "2025-10-17T08:26:04.642756Z"
    }
   },
   "outputs": [],
   "source": [
    "Z_WD_complex = (RX_WD + 1j) * Z_WD / np.sqrt(1 + RX_WD**2)\n",
    "Z_WD_complex # Ohm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.698506Z",
     "start_time": "2025-10-17T08:26:04.682279Z"
    }
   },
   "outputs": [],
   "source": [
    "ikss_ka = 1.1 * 20 / (np.sqrt(3) * Z_WD)\n",
    "ikss_ka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.745482Z",
     "start_time": "2025-10-17T08:26:04.723370Z"
    }
   },
   "outputs": [],
   "source": [
    "# skss\n",
    "ikss_ka * 20 * np.sqrt(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:04.808621Z",
     "start_time": "2025-10-17T08:26:04.781645Z"
    }
   },
   "outputs": [],
   "source": [
    "ikss_ka * k_WD * np.sqrt(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:05.415771Z",
     "start_time": "2025-10-17T08:26:04.845718Z"
    }
   },
   "outputs": [],
   "source": [
    "%%capture\n",
    "# now with pandapower:\n",
    "net = create_net(\"async_doubly_fed\")\n",
    "sc.calc_sc(net, ip=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:05.493359Z",
     "start_time": "2025-10-17T08:26:05.445506Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.sgen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:05.772900Z",
     "start_time": "2025-10-17T08:26:05.755332Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.res_bus_sc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Wind power station unit with full size converter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A typical range of short-circuit current contribution of a full size converter is 1.0 to 1.3 of the rated current $I_{rWF}$.\n",
    "The wind power station unit with full size converter is considered as a current source, therefore the impedance is infinitely high:\n",
    "\n",
    "$Z_{WF} = \\infty$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Required input parameters:\n",
    "* U_rG: rated voltage of the asynchronous generator (we take from the bus)\n",
    "* I_rG: rated current of the asynchronous generator (calculated from S_rG and U_rG)\n",
    "* S_rG: rated apparent power of the asynchronous generator (required input)\n",
    "* R_G/X_G: R to X value of the asynchronous generator (required input)\n",
    "* k: the factor of the short-circuit contribution of the full size converter in relation to its rated current (typically in the range between 1 and 1.3, depends on the requirements of the system operator)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:06.085495Z",
     "start_time": "2025-10-17T08:26:06.064921Z"
    }
   },
   "outputs": [],
   "source": [
    "S_rWF = 2.5 # MVA\n",
    "U_rWF = 20 # kV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:06.355398Z",
     "start_time": "2025-10-17T08:26:06.344555Z"
    }
   },
   "outputs": [],
   "source": [
    "I_rWF = S_rWF / (np.sqrt(3) * U_rWF)\n",
    "I_rWF # kA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:06.490895Z",
     "start_time": "2025-10-17T08:26:06.475658Z"
    }
   },
   "outputs": [],
   "source": [
    "I_skWF = I_kWFmax = 1.3 * I_rWF\n",
    "I_skWF # kA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:06.553567Z",
     "start_time": "2025-10-17T08:26:06.529263Z"
    }
   },
   "outputs": [],
   "source": [
    "kappa = 1.02 + 0.98 * np.exp(-3*0.1)\n",
    "I_skWF * np.sqrt(2) # because single power station unit with full size converter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:06.629887Z",
     "start_time": "2025-10-17T08:26:06.591504Z"
    }
   },
   "outputs": [],
   "source": [
    "# skss\n",
    "I_skWF * 20 * np.sqrt(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:07.696601Z",
     "start_time": "2025-10-17T08:26:06.679239Z"
    }
   },
   "outputs": [],
   "source": [
    "%%capture\n",
    "# now with pandapower:\n",
    "net = create_net(\"current_source\")\n",
    "sc.calc_sc(net, ip=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:07.774899Z",
     "start_time": "2025-10-17T08:26:07.716995Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.sgen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:26:08.170519Z",
     "start_time": "2025-10-17T08:26:08.149701Z"
    }
   },
   "outputs": [],
   "source": [
    "display(net.res_bus_sc)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
